package test

import (
	"flag"
	"fmt"
)

/**
** @author: hui
** @email: 3231954428@qq.com
** @phone: 15779563913
** @DataTime: 2022/4/1 10:12
**/

func main() {
	var a int
	var b int

	args := flag.Args()
	set := flag.NewFlagSet("Sum", flag.ExitOnError)
	//加
	if args[1] == "sum"{
		set.IntVar(&a, "Sum", 0, "")
		set.IntVar(&b, "Sum", 0, "")
		_ = set.Parse(args[2:])
		fmt.Println(Sum(a, b))
	}

	//减
	if args[1] == "Sub"{
		set.IntVar(&a, "Sub", 0, "")
		set.IntVar(&b, "Sub", 0, "")
		_ = set.Parse(args[2:])
		fmt.Println(Sum(a, b))
	}
}

func Sum (a int, b int) int{
	return a + b
}

func Sub(a int, b int) int{
	return a - b
}